// app.js
App({
  globalData: {},
 baseURL: 'https://api.it120.cc/conner',
 request(url, config = {}) {
   // 显示loading
   wx.showLoading({
    title:'加载中...'
  })
  
   return new Promise((resolve, reject) => {
    wx.request({
      url: this.baseURL+url,
      data: config.data || '',
      method:config.method || 'GET',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      },
      complete: () => {
        wx.hideLoading()
      }
    })
  
  })
 },
 isLogin() {
  return !!wx.getStorageSync('token')
 },
 getToken(){
  return wx.getStorageSync('token')
},
// 这是一个简易版的vueX
  // 里面存储多个页面的公共状态
  globalData: {
    navHeight: 0,
    navPaddingTop: 0,
    from: ''
  }
})
